﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Text;

namespace MultLanguage.NLS
{
    public class NLSCollection : ConfigurationElementCollection
    {
        public NLSCollection()
            : base(StringComparer.OrdinalIgnoreCase)  //忽略大小写
        {

        }

        //关键索引器,关键词
        new public NLSElement this[string name]
        {
            get
            {
                return (NLSElement)base.BaseGet(name);
            }
        }

        //关键索引器,顺序索引
        public NLSElement this[int index]
        {
            get
            {
                return (NLSElement)base.BaseGet(index);
            }
        }

        //下面二个方法中抽象类中必须要实现的
        protected override ConfigurationElement CreateNewElement()
        {
            return new NLSElement();
        }

        protected override object GetElementKey(ConfigurationElement element)
        {
            return ((NLSElement)element).Code;
        }

        //说明：如果不需要在代码中修改集合，可以不实现Add,Clear,Remove
        public void Add(NLSElement setting)
        {
            this.BaseAdd(setting);
        }

        public void Clear()
        {
            this.BaseClear();
        }

        public void Get(NLSElement setting)
        {
            this.BaseGet(setting.Code);
        }

        public void Remove(string name)
        {
            base.BaseRemove(name);
        }
    }
}
